<?php
namespace Index\TagLib;
use Think\Template\TagLib;
defined('THINK_PATH') or exit();
/**
 * 自定义标签
 */
class Yh extends TagLib{
	protected $tags = array(
		// 标签定义： attr 属性列表 close 是否闭合（0 或者1 默认1） alias 标签别名 level 嵌套层次
		'nav'		=>	array('attr'=>'pid,order'),
		);
	/**
	 * 导航标签
	 * @param  [type] $tag     [description]
	 * @param  [type] $content [description]
	 * @return [type]          [description]
	 */
	public function _nav($tag,$content){
		$pid = $tag['pid'];
		$order = $tag['order'];
		$str = '<?php ';
		$str.= "\$_cate = M('category')->order('".$order."')->where(array('pid'=>".$pid."))->select(); ";
		$str.= "foreach(\$_cate as \$_cate_v): extract(\$_cate_v); \$url = U('Index/list/'.\$id); ?>";
		$str.= $content;
		$str.= "<?php endforeach; ?>";
		return $str;
	}
}